/**
 * 
 */
package org.cuatrovientos.erp.business;

import java.util.List;

import org.apache.log4j.Logger;
import org.cuatrovientos.erp.dao.CountryDAOInterface;
import org.cuatrovientos.erp.model.Country;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author pablo_guerrero
 * This class implements CountryBOInterface
 */
public class CountryBO implements CountryBOInterface{
	// Get log4j logger
		private static final Logger logger = Logger.getLogger(CountryBO.class);
		
		@Autowired
	    private CountryDAOInterface countryDAO;
		
	/**
	 * @param int id
	 * @return Country country
	 * This method returns a country selected by it's id
	 */
	@Override
	public Country selectById(int id) {
		logger.info("selectById: " + id);
		return countryDAO.selectById(id);
	}
	
	/**
	 * @return All the countries we have in the database
	 */
	@Override
	public List<Country> selectAll() {
		logger.info("selectAll: ");
		return countryDAO.selectAll();
	}
	
	/**
	 * @return The number of countries we have in the database
	 */
	@Override
	public List<Country> search(String name) {
		logger.info("search : " + name);
		return countryDAO.search(name);
	}
	
	/**
	 * @param int id
	 * This method deletes the country selected by id
	 */
	@Override
	public void deleteById(int id) {
		logger.info("delete by: " + id + " id");
		countryDAO.deleteById(id);
	}
	
	/**
	 * @param Country country
	 * This method insert a country in the database passed by parameter
	 */
	@Override
	public void insert(Country country) {
		logger.info("insert: " + country);
		countryDAO.insert(country);
	}
	
	/**
	 * @param Country country
	 * This method updates a country passed by parameter
	 */
	@Override
	public void update(Country country) {
		logger.info("update: " + country);
		countryDAO.update(country);
	}
	
	/**
	 * @param Country role
	 * This method deletes a country passed by parameter
	 */
	@Override
	public void delete(Country country) {
		logger.info("delete: " + country);
		countryDAO.delete(country);
	}

}
